package com.zzyl.controller.security;

import com.zzyl.base.ResponseResult;
import com.zzyl.dto.LoginDto;
import com.zzyl.utils.JwtUtil;
import com.zzyl.vo.UserVo;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * PC端登录管理
 */
@RequestMapping("/security")
@RestController
@Api(tags = "登录管理")
@RequiredArgsConstructor
public class UserLoginController {
	/**
	 * TODO 待改造的登录接口，这里仅仅是模拟登录
	 */
	@PostMapping("/login")
	public ResponseResult login(@RequestBody LoginDto loginDto) {
		
		UserVo userVo = new UserVo();
		
		Map<String, Object> map = new HashMap<>();
		map.put("username", loginDto.getUsername());
		
		userVo.setUserToken(JwtUtil.createJWT("itheima", 600000, map));
		return ResponseResult.success(userVo);
	}
}